package com.longcai.piaojia.wxapi;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import com.longcai.piaojia.activity.DepositActivity;
import com.tencent.mm.sdk.modelbase.BaseReq;
import com.tencent.mm.sdk.modelbase.BaseResp;
import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.IWXAPIEventHandler;
import com.tencent.mm.sdk.openapi.WXAPIFactory;

/**
 * Created by Administrator on 2016/7/25.
 */
public class WXPayEntryActivity extends Activity implements IWXAPIEventHandler {

    private IWXAPI api;
    private Intent intent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        api = WXAPIFactory.createWXAPI(this, "wx91696f9a0eceabed", false);

        api.handleIntent(getIntent(), this);

    }

    @Override
    public void onReq(BaseReq baseReq) {

    }

    @Override
    public void onResp(BaseResp baseResp) {

        if(baseResp.errCode==0){

            sendBroadcast(new Intent("payBroadcastReceiver"));

        }else{

            sendBroadcast(new Intent("payBroadcastFinishReceiver"));

        }

        sendBroadcast(new Intent(DepositActivity.RECHARGE_FILTER));

        finish();

    }

}
